const execSync = require('child_process').execSync;

try {
  execSync('npm install');
  execSync('cd serve');
  execSync('npm install');
  console.log('初始化成功！\r\n请使用 npm run listen 命令开启测试服务器。');
} catch (error) {
  console.log(error)
  initErrorCallback();
}

function initErrorCallback () {
  console.log([
    '初始化失败！请手动依次执行以下命令进行初始化：',
    'npm install',
    'cd serve',
    'npm install'
  ].join('\r\n\r\n'));
}